:- import "%%/lib/list.sl" #


-- Dynamic Clauses Implementation (using get/set) --

insert .clause :- inserta .clause #

inserta .clause :-
	getClauseList .clause .list,
	setClauseList .clause (.clause, .list) ! #

insertz .clause :-
	getClauseList .clause .list,
	list.append .list (.clause,) .list1,
	setClauseList .clause .list1 ! #

delete .clause :-
	getClauseList .clause .list,
	list.remove .list .clause .list1,
	setClauseList .clause .list1 ! #

delete.all .clause :-
	forall (search .clause) (delete .clause) #

search .clause :-
	getClauseList .clause .list, list.member .list .clause #

getClauseName .clause .name :-
	nth .clause 0 .name, bound .name ! #
getClauseName . CLAUSE #

getClauseList .clause .list :-
	getClauseName .clause .name, get .name .list ! #
getClauseList . $ #

setClauseList .clause .list :-
	getClauseName .clause .name, set .name .list #
